package com.dongxing.concyrrency.chapter1;

/**
 * @author XavierDong
 **/
public abstract class TemplateMethod {


    public final void print(final String message) {
        System.out.println("####################");
        wrapPrint(message);
        System.out.println("####################");
    }

    protected abstract void wrapPrint(final String message);

    public static void main(String[] args) {
        TemplateMethod t1 = new TemplateMethod() {
            @Override
            protected void wrapPrint(String message) {
                System.out.println("*" + message + "*");
            }
        };

        t1.print("Hello Thread!");


        TemplateMethod t2 = new TemplateMethod() {
            @Override
            protected void wrapPrint(String message) {
                System.out.println("+" + message + "+");
            }
        };

        t2.print("Hello Thread!");
    }

}
